package main;

import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;

import control.ControlCommand;
import control.GroupControl;
import control.TextButton;
import control.TextControl;

public class HelpCanvas extends Canvas{
	MainMidlet midlet;
	GroupControl controls;
	static String []strings= new String[]{
		"  + INTRODUCTION\n\n" +
		"Mobile Pixel Art is a software for \ncreating pixel art pictures. You can\nexport your work as PNG file",
		"  + NEW PROJECT\n\n" +
		"From menu screen, sellect \'New art\'\nwith the size you want\n\n" +
		"  \'New art 16x16\' to create 16x16\npixel canvas\n\n" +
		"  \'New art 32x32\' to create 32x32\npixel canvas\n\n" +
		"  \'New art 64x64\' to create 64x64\npixel canvas\n\n" +
		"  \'New art 96x96\' to create 96x96\npixel canvas\n\n",
		"  + BASIC\n\n" +
		"Press on a pixel on the canvas to set\ncurrent color to that pixel\n\n" +
		"Drag to move the canvas\n\n" +
		"Long Press on a pixel to pick the\ncolor on that pixel",
		"  + COLOR\n\n" +
		"There are two boxes of color $(3)\n\n" +
		"The right box is the first/drawing\ncolor.You can sellect new first\ncolor by click on that box\n\n" +
		"The left box is the second color. \nWhen you sellect a new first\n" +
		"color,the second color is auto\nchanged to your previous first\n" +
		"color.By click on second color box,\nyou can change first color to\nyour second color",
		"  + TOOL\n\n" +
		"$(4)Pen - free-hand draw \n\n" +
		"$(5)FloodFill - fill a color region\n\n" +
		"$(6)ColorPicker - pick a color\non the canvas\n\n" +
		"$(7)Undo - undo the last action",
		"  + MINI VIEW\n\n" +
		"Mini view on the top right of the\nscreen nhelp you review your work.\n" +
		"Click on it to expand or collapse it",
		"  + ZOOM\n\n" +
		"There is a zoom slider on the top left\nof the screen",
		"  + IMAGE OPTION\n\n" +
		"Click on $(2) to see more image\naction",
		"  + COLOR REPLACE\n\n" +
		"Replace the second color with first\ncolor",
		"  + MOVE IMAGE\n\n" +
		"You can adjust the image's position\non the canvas. Drag on the screen",
		"  + SAVE IMAGE\n\n" +
		"Save - save project to edit it later\n\n" +
		"Auto save - your project is saved\nautomaticlly when you close the\n" +
		"application. Sellect \'Current art\' to\nrestore your last project\n\n" +
		"Export PNG - save the png file to\nyour galery."
		};
	int currentIndex = 0;
	//TextButton button;
	public HelpCanvas(MainMidlet mid) {
		this.midlet = mid;
		setFullScreenMode(true);
		final TextControl text = new TextControl(strings[0], 10, 10);
		controls = new GroupControl(4);
		controls.setControl(0, text);
		
		controls.setControl(1, new TextButton("<<", 10, 360, 80, 30));
		controls.get(1).setCommand(new ControlCommand() {
			public void Do() {

				if(currentIndex==0){
					currentIndex = strings.length;
				}
				currentIndex--;
				text.setText(strings[currentIndex]);
			}
		});
		controls.setControl(2, new TextButton(" Menu", 95, 360, 80, 30));
		controls.get(2).setCommand(new ControlCommand() {
			public void Do() {
				
				midlet.showMenuCanvas();
			}
		});
		controls.setControl(3, new TextButton(">>", 200, 360, 80, 30));
		controls.get(3).setCommand(new ControlCommand() {
			public void Do() {
				currentIndex++;
				if(currentIndex==strings.length){
					currentIndex = 0;
				}
				text.setText(strings[currentIndex]);
			}
		});
		/*
		this.button = new TextButton("Ok", 10, 360, 120, 30);
		this.button.setCommand(new ControlCommand() {
			public void Do() {
				midlet.showMenuCanvas();
			}
		});*/
		
		
	}
	protected void pointerReleased(int x, int y) {
		controls.pointerReleased(x, y);
		repaint();
	}
	protected void pointerPressed(int x, int y) {
		controls.pointerPressed(x, y);
		repaint();
	}

	protected void pointerDragged(int x, int y) {
		controls.pointerPressed(x, y);
		repaint();
		
	}
	protected void paint(Graphics g) {
		// TODO Auto-generated method stub
		g.setColor(0xff666666);
		g.fillRect(0, 0, 240, 400);
		g.setColor(0xffffffff);
		controls.paint(g);
	}
}
